<template>
  <el-scrollbar height="400px">
    <el-row>
      <el-col :span="4">
        <div class="grid-content bg-purple">
          序号
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content bg-purple-light">
          任务ID
        </div>
      </el-col>
      <el-col :span="8">
        <div class="grid-content bg-purple">
          状态
        </div>
      </el-col>
      <el-col :span="8">
        <div class="grid-content bg-purple-light">
          操作
        </div>
      </el-col>
    </el-row>

    <el-row v-for="(value,index) in res2 " :key="index">
      <el-col :span="4">
        <div class="grid-content bg-purple">
          {{ index + 1 }}
        </div>
      </el-col>
      <el-col :span="4">
        <div class="grid-content  bg-purple-light">
          {{ value.id }}
        </div>
      </el-col>
      <el-col :span="8">
        <div class="grid-content bg-purple">
          待完成
        </div>
      </el-col>
      <el-col :span="8">
        <div class="grid-content  bg-purple-light">
          <el-button @click="mange(value.id)">管理</el-button>
        </div>
      </el-col>
    </el-row>

  </el-scrollbar>
</template>

<script setup lang="ts">
import {Action, ElMessage, ElMessageBox} from "element-plus";
import {ref} from "vue";
import router from "@/router";
import getRoughListById from "@/api/task/getList/getRoughListById";

const userId = sessionStorage.getItem("user.id");
const res = getRoughListById(parseInt(userId));
let res2 = ref<[]>([]);
res.then((data) => {
  for (let i = 0; i < data.length; i++) {
    res2.value?.push(data[i]);
  }
})


const mange = (id: number) => {


  ElMessageBox.confirm('进入工作台', '确定', {
    confirmButtonText: 'OK',
    callback: (action: Action) => {
      if (action == "confirm") {
        console.log(id)
        router.push("/task/workbench/rough");
      }
      ElMessage({
        type: 'info',
        message: `action: ${action}`,
      })
    },
  })

}

</script>

<style scoped>

.el-row {
  margin-bottom: 20px;
}

.el-row:last-child {
  margin-bottom: 0;
}

.el-col {
  border-radius: 4px;
}

.bg-purple-dark {
  background: #99a9bf;
}

.bg-purple {
  background: #d3dce6;
}

.bg-purple-light {
  background: #e5e9f2;
}

.grid-content {
  border-radius: 4px;
  min-height: 36px;
}

.row-bg {
  padding: 10px 0;
  background-color: #f9fafc;
}

.scrollbar-demo-item {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 50px;
  margin: 10px;
  text-align: center;
  border-radius: 4px;
  background: var(--el-color-primary-light-9);
  color: var(--el-color-primary);
}
</style>